package com.example.compose.jetsurvey.survey

import android.net.Uri
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import com.example.compose.R
import com.example.compose.jetsurvey.survey.question.DateQuestion
import com.example.compose.jetsurvey.survey.question.MultipleChoiceQuestion
import com.example.compose.jetsurvey.survey.question.PhotoQuestion
import com.example.compose.jetsurvey.survey.question.SingleChoiceQuestion
import com.example.compose.jetsurvey.survey.question.SliderQuestion
import com.example.compose.jetsurvey.survey.question.SuperHero

@Composable
fun FreeTimeQuestion(
    modifier: Modifier = Modifier,
    onOptionSelected: (selected: Boolean, answer: Int) -> Unit,
    selectedAnswers: List<Int>
) {
    MultipleChoiceQuestion(
        titleResourceId = R.string.in_my_free_time,
        directionResourceId = R.string.select_all,
        possibleAnswers = listOf(
            R.string.read,
            R.string.work_out,
            R.string.draw,
            R.string.play_games,
            R.string.dance,
            R.string.watch_movies
        ),
        selectedAnswers = selectedAnswers,
        onOptionSelected = onOptionSelected,
        modifier = modifier
    )
}

@Composable
fun SuperHeroQuestion(
    modifier: Modifier = Modifier,
    selectedAnswers: SuperHero?,
    onOptionSelected: (SuperHero) -> Unit
) {
    SingleChoiceQuestion(
        titleResourceId = R.string.pick_superhero,
        directionsResourceId = R.string.select_one,
        possibleAnswers = listOf(
            SuperHero(stringResourceId = R.string.spark, imageResourceId = R.drawable.nox),
            SuperHero(stringResourceId = R.string.spark, imageResourceId = R.drawable.koda),
            SuperHero(stringResourceId = R.string.spark, imageResourceId = R.drawable.lola),
            SuperHero(stringResourceId = R.string.spark, imageResourceId = R.drawable.bella),
            SuperHero(stringResourceId = R.string.spark, imageResourceId = R.drawable.leroy),
            SuperHero(stringResourceId = R.string.spark, imageResourceId = R.drawable.tzeitel)
        ),
        selectedAnswer = selectedAnswers,
        onOptionSelected = onOptionSelected,
        modifier = modifier
    )
}

@Composable
fun TakeawayQuestion(
    modifier: Modifier = Modifier,
    dateInMillis: Long?,
    onClick: () -> Unit
) {
    DateQuestion(
        titleResourceId = R.string.takeaway,
        directionsResourceId = R.string.select_date,
        dateInMillis = dateInMillis,
        onClick = onClick,
        modifier = modifier
    )
}

@Composable
fun FeelingAboutSelfiesQuestion(
    value: Float?,
    onValueChange: (Float) -> Unit,
    modifier: Modifier = Modifier
) {
    SliderQuestion(
        titleResourceId = R.string.selfies,
        startTextResourceId = R.string.strongly_dislike,
        neutralTextResourceId = R.string.neutral,
        endTextResourceId = R.string.strongly_like,
        value = value,
        onValueChange = onValueChange,
        modifier = modifier
    )
}

@Composable
fun TaskSelfieQuestion(
    imageUri: Uri?,
    getNewImageUri: () -> Uri,
    onPhotoTaken: (Uri) -> Unit,
    modifier: Modifier = Modifier
) {
    PhotoQuestion(
        titleResourceId = R.string.selfie_skills,
        imageUri = imageUri,
        getNewImageUri = getNewImageUri,
        onPhotoTaken = onPhotoTaken,
        modifier = modifier
    )
}